﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Text;

namespace VideoPortal.Extensions
{
    public static class HtmlHelpers
    {

        public static MvcHtmlString Social_Facebook(this HtmlHelper htmlHelper, string title, string url = "")
        {

            dynamic str = new StringBuilder();

            TagBuilder social_link = new TagBuilder("div");
            social_link.Attributes.Add("class", "fb-like");
            social_link.Attributes.Add("data-send", "false");
            social_link.Attributes.Add("data-layout", "button_count");
            social_link.Attributes.Add("data-show-faces", "false");
            social_link.Attributes.Add("data-font", "arial");


            if (!string.IsNullOrEmpty(url))
            {
                social_link.Attributes.Add("data-href", url);

            }

            str.Append(social_link.ToString(TagRenderMode.Normal));

            return new MvcHtmlString(str.ToString());
        }

        public static MvcHtmlString Social_GooglePlusOne(this HtmlHelper htmlHelper, string title, string url = "")
        {

            TagBuilder social_link = new TagBuilder("div");

            social_link.Attributes.Add("class", "g-plusone");
            social_link.Attributes.Add("data-size", "medium");
            //social_link.Attributes.Add("data-size", "small")


            if (!string.IsNullOrEmpty(url))
            {
                social_link.Attributes.Add("data-href", url);

            }

            return new MvcHtmlString(social_link.ToString(TagRenderMode.Normal));
        }

        public static MvcHtmlString Social_Twitter(this HtmlHelper htmlHelper, string title, string url = "")
        {

            TagBuilder social_link = new TagBuilder("a");

            social_link.Attributes.Add("href", "https://twitter.com/share");
            social_link.Attributes.Add("class", "twitter-share-button");
            social_link.Attributes.Add("data-via", "MY-TWITTER-HANDLE");
            social_link.Attributes.Add("data-count", "horizontal");
            social_link.Attributes.Add("data-text", title);
            social_link.SetInnerText("Tweet");


            if (!string.IsNullOrEmpty(url))
            {
                social_link.Attributes.Add("data-url", url);

            }

            return new MvcHtmlString(social_link.ToString(TagRenderMode.Normal));
        }

        public static MvcHtmlString Social_AllButtons(this HtmlHelper htmlHelper, string title, string url = "")
        {

            dynamic str = new StringBuilder();

            TagBuilder ul = new TagBuilder("ul");
            ul.AddCssClass("social");

            //Google
            TagBuilder li3 = new TagBuilder("li");
            li3.InnerHtml = htmlHelper.Social_GooglePlusOne(title, url).ToHtmlString();
            li3.AddCssClass("social-google");
            ul.InnerHtml += li3.ToString();

            //Twitter
            TagBuilder li2 = new TagBuilder("li");
            li2.InnerHtml = htmlHelper.Social_Twitter(title, url).ToHtmlString();
            li2.AddCssClass("social-twitter");
            ul.InnerHtml += li2.ToString();

            //facebook
            TagBuilder li1 = new TagBuilder("li");
            li1.InnerHtml = htmlHelper.Social_Facebook(title, url).ToHtmlString();
            li1.AddCssClass("social-facebook");
            ul.InnerHtml += li1.ToString();
            str.Append(ul.ToString(TagRenderMode.Normal));

            return new MvcHtmlString(str.ToString());
        }


    }
}